Skip to content

Support Emacs HEAD(32)#809

Merged
zonuexe merged 6 commits into
masterfrom
fix/support-emacs32
Jul 9, 2026
Merged

Support Emacs HEAD(32)#809
zonuexe merged 6 commits into
masterfrom
fix/support-emacs32

Conversation

@zonuexe

@zonuexe zonuexe commented Jul 2, 2026

Copy link
Copy Markdown
Member

This PR makes php-mode work on Emacs HEAD (the future Emacs 32) while keeping Emacs 27 through 30 working.

CI is green on Emacs 27.2, 28.2, 29.4, 30.2, and snapshot across Linux, macOS, and Windows.

CC Mode regressions in Emacs 31 and later

Two defects come from CC Mode changes that landed between Emacs 30.2 and 31.0.90.
Both are masked on older Emacs and only appear from 31 onward.

Closure body indentation

The change for bug#19867 made c-looking-at-statement-block stop treating a brace block as a statement block when its content is inconclusive, for example a closure body whose first line is only a comment.
CC Mode then falls back to context analysis.
For an anonymous function () { ... } the token before the parameter list is the function keyword rather than a function name, so the body is classified as a brace list.
That mis-indents both the body and its closing brace.
The lang/function/closure.php indentation test fails on Emacs 31 and 32 but passes on 30.2.

Fix: advise c-looking-at-statement-block to report a closure opening brace as a statement block.
A closure body always is one, so the advice is also correct on Emacs versions that are not affected.

Error control operator @

CC Mode 31 fontifies a bare @ as a keyword, because @new is registered in c-type-list-kwds.
The error control operator in @fopen(...) or @$a was highlighted as php-keyword instead of php-errorcontrol-op.
The old matcher \<\(@\) never matched anything, because @ has punctuation syntax and a word boundary can never precede it.
The lang/errorcontrol.php faces test fails on Emacs 31 and 32.

Fix: replace the matcher with a function that highlights a single @ as the error control operator with override, while skipping @ inside strings and comments and the @new keyword.
The match data is guarded with save-match-data, because php-in-string-or-comment-p calls syntax-ppss, which can run syntax-propertize and clobber the match set for font-lock.

Other Emacs HEAD compatibility fixes

c-after-brace-list-decl-kwds

CC Mode renamed c-after-brace-list-decl-kwds to c-after-enum-list-kwds.
Keep the old name defined so the transitional lookup in cc-langs stays quiet.

rx forms

Replace bare any with nonl in several rx patterns.
Both match any character except newline, and nonl states the intent directly.

Obsolete font-lock variables

Several font-lock-*-face variables are now obsolete.
Wrap the assignments in with-suppressed-warnings to silence byte-compile warnings without changing behavior.

@zonuexe zonuexe mentioned this pull request Jul 5, 2026
zonuexe added 3 commits July 10, 2026 04:25
CC Mode >= 31 (the change for bug#19867) no longer treats a brace block
whose contents are inconclusive -- e.g. a closure body whose first line
is only a comment -- as a statement block.  `c-looking-at-statement-block'
now falls back to context analysis, and for an anonymous PHP `function
() {...}' the token before the parameter list is the `function' keyword
rather than a function-name identifier, so the body is misclassified as a
brace list.  This mis-indents both the body and its closing brace (the
`lang/function/closure.php' indentation test fails on Emacs 31/32 but
passes on 30.2).

Advise `c-looking-at-statement-block' to report a closure-opening brace
as a statement block.  A closure body always is one, so this is also
correct on Emacs versions unaffected by the change.
CC Mode >= 31 fontifies a bare `@' as a keyword because `@new' is
registered in `c-type-list-kwds', so the error-control operator in e.g.
`@fopen(...)' or `@$a' was highlighted as `php-keyword' rather than
`php-errorcontrol-op' (the `lang/errorcontrol.php' faces test fails on
Emacs 31/32).

The previous matcher `\<\(@\)' never matched: `@' has punctuation
syntax, so a word boundary can never precede it.  Replace it with a
matcher function that highlights a single `@' as the error-control
operator, overriding CC Mode's keyword face, while skipping `@' inside
strings and comments and the `@new' keyword.
`php-in-string-or-comment-p' calls `syntax-ppss', which may trigger
`syntax-propertize' and clobber the match data set by the preceding
`re-search-forward'.  That could misplace the `@new' look-ahead check
and the face applied by font-lock.  Wrap the call in `save-match-data'
so the matched `@' is preserved.
@zonuexe zonuexe merged commit 86e788e into master Jul 9, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant